package main

import (
	"database/sql"
	"github.com/go-sql-driver/mysql"
	_ "github.com/go-sql-driver/mysql"
	"log"
)

var pool *sql.DB

func init() {
	conf := &mysql.Config{
		User:   "root",
		Passwd: "123456",
		Net:    "tcp",
		Addr:   "127.0.0.1:3306",
	}

	conn, err := sql.Open("mysql", conf.FormatDSN())
	if err != nil {
		log.Fatal(err)
	}

	pool = conn
}

func main() {
	query, err := pool.Query("show variables like 'version'")
	if err!=nil {
		log.Fatal(err)
	}

	var version []string
	err = query.Scan(&version)
	defer pool.Close()
}
